<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>GT pro钱包</title>
		<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
		<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.min.css">
		<link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.min.css">
		<link rel="stylesheet" href="bower_components/Ionicons/css/ionicons.min.css">
		<link rel="stylesheet" href="dist/css/AdminLTE.min.css">
		<link rel="stylesheet" href="dist/css/skins/skin-blue.min.css">
		<link rel="stylesheet" href="css/style.css">
		<link rel="stylesheet" href="css/card.css">
		<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
		<link rel="stylesheet" href="bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css">
		<link rel="stylesheet" href="bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css">
		<style>
			.notice_content{
				width:200px;
				max-height:60px;
				white-space: nowrap;
    			overflow: hidden;
    			text-overflow: ellipsis;
			}
			.notice_content p{
				margin-bottom:0;
			}
		</style>
	</head>

	<body class="hold-transition skin-blue sidebar-mini">
		<div class="wrapper">
			<div class="content-wrapper">
				<section class="content-header ">
					<ol class="breadcrumb">
						<li>
							<a href="#"><i class="fa fa-dashboard"></i>系统设置</a>
						</li>
						<li class="active">文章管理</li>
					</ol>
				</section>
				<section class="content">
					<div class="box box-primary">
						<div class="box-header with-border">
							<div class="">
								<div class="inline-block">
									<div class="col-sm-12 row" style="margin: 10px 0;">
										<button class="btn bg-blue" onclick=localStorage.setItem('G_operation',0);location.href='notice_list_add.html'>
											<i class="fa fa-plus"></i> 添加公告
										</button>
									</div>
								</div>
							</div>
							<!-- /.box-tools -->
						</div>
						<div class="box-body">
							<div class="about_card">
								<div class="details_card">
									<table id="example" class="table table-bordered table-hover picTable" style="width:100%;">
										<thead>
											<tr>
												<th>ID</th>
												<th>时间</th>
												<th>标题</th>
												<th>内容</th>
												<th>访问链接</th>
												<th>操作</th>
											</tr>
										</thead>
										<tbody></tbody>
									</table>
								</div>
							</div>
						</div>
					</div>
					<div class="modal fade" id="modal-del1">
						<div class="modal-dialog">
							<div class="modal-content">
								<div class="modal-header">
									<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
				                  <h4 class="modal-title">删除文章</h4>
								</div>
								<div class="modal-body">
									<p>是否删除该文章？</p>
								</div>
								<div class="modal-footer">
									<button type="button" class="btn btn-default pull-left" data-dismiss="modal">返回</button>
									<button type="button" class="btn btn-primary" id="del1-sure" data-interface="Back_NoticeDel">确定</button>
								</div>
							</div>
						</div>
					</div>
				</section>
			</div>
		</div>
		<script src="bower_components/jquery/dist/jquery.min.js"></script>
		<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
		<script src="dist/js/adminlte.min.js"></script>

		<script src="bower_components/datatables.net/js/jquery.dataTables.min.js"></script>
		<script src="bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
		<script src="bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>

		<!--<script src="bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>-->
		<script src="plugins/timepicker/bootstrap-timepicker.min.js"></script>
		<script src="bower_components/moment/min/moment.min.js"></script>
		<script src="bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>
		<script src="js/clipboard.min.js"></script>
		<script src="js/argument.js"></script>
		<script src="js/fun.js"></script>
		<script src="js/nav.js"></script>
		<script src="js/pop.js"></script>
		<script type="text/javascript">
			var linkUrl = window.location.href.split("back")[0]
			//初始化表格
			var table = $('#example').DataTable({
				'ordering': false,
				'lengthChange': false,
				'searching': false,
				'info': true,
				"processing": true,
				"serverSide": true,
				"scrollX":true,
				"ajax" : {
					"type" : 'post',
					"url" : url+'/Back_NoticeList',
					"contentType": "application/x-www-form-urlencoded",
					headers: {
						"auth-token": localStorage.getItem("wallet_token")
					},
					
					"data" : function(d){
						var Json = {}//renderData(dataType);
						Json.page_num = d.start / 10 + 1;
						var data = {};
						data.data = JSON.stringify(Json);
						return data;
					},
					"dataFilter": function(data) {
						var datajson = eval('(' + data + ')');
						if(datajson.status == 1000||datajson.status == 102) {
							ToLogin(datajson)
							return false;
						} else if(datajson.status != 1) {
							alert(datajson.error);
							return false;
						}
						var json = {};
						if(datajson.data == null) {
							json.recordsTotal = 0;
							json.recordsFiltered = 0;
							json.data = [];
							return JSON.stringify(json);
						} else {
							json.recordsTotal = datajson.data.total;
							json.recordsFiltered = datajson.data.total;
							json.data = datajson.data.data_list;
							return JSON.stringify(json);
						}
					}
				},
				"columns":[
					{data:'id'},
					{data:'add_time'},
					{data:'title'},
//					{data:'articleMenuName'},
					{
						data:null,render:function(data){
							return '<div class="notice_content">'+data.content+'</div>'
						}
					},
					{
						data:null,render:function(data){
							var link = linkUrl+'back/notice_h5.html?id='+data.id
							return '<div class="notice_content lfloat link'+data.id+'" style="line-height:34px;" title="'+link+'" >'+link+'</div><button class="btn btn-success copy" data-clipboard-action="copy" data-clipboard-target=".link'+data.id+'">复制</button>'
						}
					},
					{data:null,render:function(data){
						var opera = "<button class='btn bg-primary margin' onclick=del1('id',"+data.id+")>删除</button>"
						return opera
					}},
				]
			})
			//删除
			function del1(idName,id){
				$("#del1-sure").attr('data-idName',idName)
				$("#del1-sure").attr('data-id',id)
				$("#modal-del1").modal('show')
			}
			$("#del1-sure").click(function(){
				var inter = $(this).attr('data-interface')
				var data = {
					status:2
				}
				data[$(this).attr('data-idName')] = $(this).attr('data-id')
				$.ajax({
					type:"post",
					url:url+inter,
					"contentType": "application/x-www-form-urlencoded",
					headers: {
						"auth-token": localStorage.getItem("wallet_token")
					},
					async:false,
					data:{data:JSON.stringify(data)},//JSON.stringify(data),
					success:function(res){
						if(res.status == 1000||res.status == 102){
							ToLogin(res)
						}else if(res.status==1){
							$("#modal-del1").modal('hide')
							table.ajax.reload()
							alert("删除成功")
						}else{
							alert(res.msg)
						}
					},
					error:function(res){
						error(res)
					}
				});
			})
			
			var clipboard = new ClipboardJS('.copy');

			clipboard.on('success', function(e) {
			    move('success','复制成功！');
			});
			
			clipboard.on('error', function(e) {
			   move('danger','复制失败！');
			});
		</script>
	</body>

</html>